package com.ymatou.iapi.address.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.address.parameter.PostCodeBean;
import com.ymatou.iapi.address.service.PostCodeCall;
import com.ymt.base.YmatouEasyCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymttest.utils.DiffUtil;

@TestSuite
public class Ts_PostCode {
	private static PostCodeCall postCodeCall;
	private static PostCodeBean postCodeBean;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("查看地址接口");
	}

	@Before
	public void caseUp() {
		postCodeCall = new PostCodeCall();
		postCodeBean=new PostCodeBean();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(postCodeCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PostCode_001() {
		Logger.start(true,"查询邮编成功");
		try {
			//浙江	330000 	杭州	330100	西湖	330106
			postCodeBean.setProvince("浙江");
			postCodeBean.setCity("杭州");
			postCodeBean.setDistrict("西湖");
			postCodeBean.setAddress("具体点的地址");
			postCodeCall.setData(postCodeBean);
			postCodeCall.callService();
			Logger.verifyEquals("330106",postCodeCall.getString("postcode"),"验证postcode");
//			Logger.verifyEquals("true",postCodeCall.getString("Success"),"验证success");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PostCode_002() {
		Logger.start(true,"不输入address查询邮编成功");
		try {
			//浙江	330000 	杭州	330100	西湖	330106
			postCodeBean.setProvince("浙江");
			postCodeBean.setCity("杭州");
			postCodeBean.setDistrict("西湖区");
//			postCodeBean.setAddress("具体点的地址");
			postCodeCall.setData(postCodeBean);
			postCodeCall.callService();
			Logger.verifyEquals("330106",postCodeCall.getString("postcode"),"验证postcode");
//			Logger.verifyEquals("true",postCodeCall.getString("Success"),"验证success");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PostCode_003() {
		Logger.start(true,"不输入District查询邮编成功");
		try {
			//浙江	330000 	杭州	330100	西湖	330106
			postCodeBean.setProvince("浙江");
			postCodeBean.setCity("杭州市");
//			postCodeBean.setDistrict("西湖");
//			postCodeBean.setAddress("具体点的地址");
			postCodeCall.setData(postCodeBean);
			postCodeCall.callService();
			Logger.verifyEquals("330100",postCodeCall.getString("postcode"),"验证postcode");
//			Logger.verifyEquals("true",postCodeCall.getString("Success"),"验证success");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PostCode_004() {
		Logger.start(true,"不输入city查询邮编成功");
		try {
			//浙江	330000 	杭州	330100	西湖	330106
			postCodeBean.setProvince("浙江省");
//			postCodeBean.setCity("杭州");
//			postCodeBean.setDistrict("西湖");
//			postCodeBean.setAddress("具体点的地址");
			postCodeCall.setData(postCodeBean);
			postCodeCall.callService();
			Logger.verifyEquals("330000",postCodeCall.getString("postcode"),"验证postcode");
//			Logger.verifyEquals("true",postCodeCall.getString("Success"),"验证success");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PostCode_005() {
		Logger.start(false,"不输入Province查询邮编null");
		try {
			//浙江	330000 	杭州	330100	西湖	330106
//			postCodeBean.setProvince("浙江");
//			postCodeBean.setCity("杭州");
//			postCodeBean.setDistrict("西湖");
//			postCodeBean.setAddress("具体点的地址");
			postCodeCall.setData(postCodeBean);
			postCodeCall.callService();
			Logger.verifyEquals("null",postCodeCall.getString("postcode"),"验证postcode");
//			Logger.verifyEquals("true",postCodeCall.getString("Success"),"验证success");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_PostCode_006() {
		Logger.start(false,"查询Province香港邮编");
		try {
			postCodeBean.setProvince("香港市");
			postCodeBean.setCity("香港市");
			postCodeBean.setDistrict("香港市");
//			postCodeBean.setAddress("具体点的地址");
			postCodeCall.setData(postCodeBean);
			postCodeCall.callService();
			Logger.verifyEquals("810000",postCodeCall.getString("postcode"),"验证postcode");
//			Logger.verifyEquals("true",postCodeCall.getString("Success"),"验证success");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}